﻿function PatientListPresenter(eventHub) {
    var self = this;
    /*=========================================================================================================*/
    this.RegisterEventListeners = function() {
        eventHub.AddEventListener(PasEvents.OnLocationChanged, function(eventTypes, eventArgs) { self.LocationChanged(eventArgs); });
    };

    this.LocationChanged = function(eventArgs) {
        var listtype = $("#PatientListSelector li.selected").attr("listid");
        if (listtype = 'undefined')
            listtype = "InPatients";
        var url = "http://localhost:2000/Home/Patients/" + eventArgs.wardCode + "/?listType=" + listtype;
        var ajaxOptions = {
            url: url,
            async: false,
            cache: false,
            type: "POST",
            success: this.LocationChangedSuccess,
            error: this.LocationChangedError
        };
        $.ajax(ajaxOptions);
    };

this.LocationChangedSuccess = function(data) {
    $("#PatientLists").html(data);
};

this.LocationChangedError = function(xhr, description, error) {
    alert("LocationChangedError");

};

};